package com.example.shellshopping.YCB_settings;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.example.shellshopping.R;

public class YCBAboutActivity extends AppCompatActivity {

    Button zizhi_btn,guize_btn,jubao_btn,banquan_btn,gongxiang_btn;
    Button btn1,btn2;
    ImageView btn1_1,btn2_1,back;
    int changeColor1 = 0;
    int changeColor2 = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ycb_about_activity);
        initView();
        setListener();
    }

    private void setListener() {
        zizhi_btn.setOnClickListener(onClickListener);
        guize_btn.setOnClickListener(onClickListener);
        jubao_btn.setOnClickListener(onClickListener);
        banquan_btn.setOnClickListener(onClickListener);
        gongxiang_btn.setOnClickListener(onClickListener);
        btn1.setOnClickListener(onClickListener);
        btn2.setOnClickListener(onClickListener);
        back.setOnClickListener(onClickListener);
    }

    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.ycb_about_back:
                    finish();
                    break;
                case R.id.ycb_about_zizhi_btn:
                    jumpToZizhi();
                    break;
                case R.id.ycb_about_guize_btn:
                    jumpToGuize();
                    break;
                case R.id.ycb_about_jubao_btn:
                    jumpToJubao();
                    break;
                case R.id.ycb_about_banquan_btn:
                    jumpToBanquan();
                    break;
                case R.id.ycb_about_gongxiang_btn:
                    jumpToGongxiang();
                    break;
                case R.id.ycb_about_btn1:
                    changeFlag1();  //更换点赞和投币颜色
                    //btn1_1.setVisibility(View.VISIBLE);
                    break;
                case R.id.ycb_about_btn2:
                    changeFlag2();  //更换点赞和投币颜色
                    break;
            }
        }
    };

    private void jumpToGongxiang() {
        Intent intent = new Intent(this,YCBAboutGongxiangActivity.class);
        startActivity(intent);
    }

    private void jumpToBanquan() {
        Intent intent = new Intent(this,YCBAboutBanquanActivity.class);
        startActivity(intent);
    }

    private void jumpToJubao() {
        Intent intent = new Intent(this,YCBAboutJubaoActivity.class);
        startActivity(intent);
    }

    private void jumpToGuize() {
        Intent intent = new Intent(this,YCBAboutGuizeActivity.class);
        startActivity(intent);
    }

    private void changeFlag1() {
        if(changeColor1==0){
            btn1_1.setVisibility(View.VISIBLE);
            changeColor1=1;
        }
        else if(changeColor1==1){
            btn1_1.setVisibility(View.INVISIBLE);
            changeColor1=0;
        }
    }
    private void changeFlag2() {
        if(changeColor2==0){
            btn2_1.setVisibility(View.VISIBLE);
            changeColor2=1;
        }
        else if(changeColor2==1){
            btn2_1.setVisibility(View.INVISIBLE);
            changeColor2=0;
        }
    }

    private void jumpToZizhi() {
        Intent intent = new Intent(this,YCBAboutZizhiActivity.class);
        startActivity(intent);
    }

    private void initView() {
        zizhi_btn = findViewById(R.id.ycb_about_zizhi_btn);
        guize_btn = findViewById(R.id.ycb_about_guize_btn);
        jubao_btn = findViewById(R.id.ycb_about_jubao_btn);
        banquan_btn = findViewById(R.id.ycb_about_banquan_btn);
        gongxiang_btn = findViewById(R.id.ycb_about_gongxiang_btn);
        btn1 = findViewById(R.id.ycb_about_btn1);
        btn1_1 = findViewById(R.id.ycb_about_btn1_1);
        btn2 = findViewById(R.id.ycb_about_btn2);
        btn2_1 = findViewById(R.id.ycb_about_btn2_1);
        back = findViewById(R.id.ycb_about_back);
    }
}